package com.cloudcentral.enums;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

/**
 * Create by Administrator
 * 2023/11/24 17:52
 */
@Getter
@Schema(description = "上传类型路径")
public enum UploadTypePath {
  ICON("icon", "/icon"),
  AVATAR("avatar", "/avatar"),
  BACKGROUND("background", "/background"),
  BEST_DETECT_RESULT("bestDetectResult", "/bestDetectResult"),
  PCM("pcm", "/pcm");

  @Schema(description = "类型")
  private final String type;
  @Schema(description = "路径")
  private final String path;

  UploadTypePath(String type, String path) {
    this.type = type;
    this.path = path;
  }

  public static UploadTypePath fromType(String type) {
    if (StringUtils.isBlank(type)) return null;
    else return Arrays.stream(UploadTypePath.values()).filter(item -> item.type.equalsIgnoreCase(type)).findAny().orElse(null);
  }
}
